//
// Created by SunYing on 2017/11/2.
//

#ifndef CPP_JAVA_LEARNING_SELECTIONSORT_H
#define CPP_JAVA_LEARNING_SELECTIONSORT_H

#include <iostream>

using namespace std;

template <typename T>
void selectionSort(T arr[], int n){

    srand(time(NULL));

    for (int i = 0; i < n; ++i) {
        int minIndex = i;
        for (int j = i + 1; j < n; ++j) {
            if (arr[j] < arr[minIndex]) {
                minIndex = j;
            }
        }
        swap(arr[i], arr[minIndex]);
    }
}

#endif //CPP_JAVA_LEARNING_SELECTIONSORT_H
